package cn.edu.nju.software.cdiy.action.supplier;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.edu.nju.software.cdiy.bean.Hardware;
import cn.edu.nju.software.cdiy.bean.Supplier;
import cn.edu.nju.software.cdiy.service.Service;
import cn.edu.nju.software.cdiy.util.BusinessConstant;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class HardwareListAction<T extends Hardware> extends ActionSupport implements SessionAware {

    private Map<String, Object> session;
    private Service<T> service;
    private List<T> hardwareList;

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public void setService(Service<T> service) {
		this.service = service;
	}

	public List<T> getHardwareList() {
		return hardwareList;
	}

	@Override
	public String execute() throws Exception {
		Supplier supplier = (Supplier) session.get(BusinessConstant.S_SUPPLIER);
		hardwareList = service.getSupplierHarewares(supplier.getId());
		return SUCCESS;
	}
	
}
